#include <iostream>
#include <vector>
#include <cstdio>
#include "Calculate.h"

using namespace std;

/**
* @brief To complete a calculation.
* 
*/
int main()
{
    vector<double> num;
    vector<char> ope, store;
    Doublenum part;
    int judge = 0;
    char ch;

    // Use a circulation to make the calculation being able to work many times.
    while( 1 )
    {
        store.clear();
        num.clear();
        ope.clear();
        // If you want to calculate enter '1', otherwise enter '0'.
        cin >> judge;
        if( judge == 0 )
            break;
        while( (ch = getchar()) != 0 )
        {
            store.push_back( ch );
            int judch = Judgech( ch );
            bool corret, out;

            // Make operation on different types of enters.
            if( judch == DEFAULE )
                continue;
            else if( judch == Isnum )
                Completenum( part, ch );
            else if( judch == Ispoint )
            {
                corret = Addpoint( part );
                if( !corret )
                {
                    Puterror( store );
                    break;
                }
            }
            else if( judch == Isope )
            {
                corret = Getoperator( ope, num, part, ch );
                if( !corret )
                {
                    Puterror( store );
                    break;
                }
            }
            else if( judch == Isblank )
            {
                corret = Getoperator( ope, num, part, ch );
                if( !corret )
                {
                    Puterror( store );
                    break;
                }

                corret = Judgeempty( ope, num);
                if( !corret )
                {
                    Puterror( store );
                    break;
                }

                // Print out the arrays.
                Printout( store );
                cout << " = ";
                Printout( num );
                cout << endl;
                break;
            }
        }
    }
    return 0;
}